| Total Complexity | 4 | 
| Total Lines | 24 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import React, { Component } from 'react' | 
            ||
| 2 | |||
| 3 | export default class ErrorBoundary extends Component { | 
            ||
| 4 |   constructor(props) { | 
            ||
| 5 | super(props)  | 
            ||
| 6 |     this.state = { hasError: false } | 
            ||
| 7 | }  | 
            ||
| 8 | |||
| 9 |   static getDerivedStateFromError() { | 
            ||
| 10 |     return { hasError: true } | 
            ||
| 11 | }  | 
            ||
| 12 | |||
| 13 |   componentDidCatch(error, errorInfo) { | 
            ||
| 14 | // eslint-disable-next-line no-console  | 
            ||
| 15 | console.log(error, errorInfo)  | 
            ||
| 16 | }  | 
            ||
| 17 | |||
| 18 |   render() { | 
            ||
| 19 | // eslint-disable-next-line react/destructuring-assignment  | 
            ||
| 20 |     if (this.state.hasError) { | 
            ||
| 21 | return <h1>Something went wrong.</h1>  | 
            ||
| 22 | }  | 
            ||
| 23 | |||
| 24 | // eslint-disable-next-line react/destructuring-assignment, react/prop-types  | 
            ||
| 25 | return this.props.children  | 
            ||
| 26 | }  | 
            ||
| 28 |